import { _decorator, Component, Sprite, v3 } from 'cc';
const { ccclass, property } = _decorator;

import CardFunctions from "../Common/CardFunctions";
import { GameData } from "../Data/GameData";

@ccclass('StopBlock')
export default class StopBlock extends Component {
    @property(Sprite)
    icon: Sprite | null = null;
    col = 0;
    row = 0;
    type = 0; //1是普通，2是视频格子
    //    // 初始化
    Init(_col: number, _row: number, _type) {
        this.col = _col;
        this.row = _row;
        this.type = _type;

        this.InitPosition();
    }
    InitPosition() {
        let x = CardFunctions.Get_x_by_col(this.col);
        let y = CardFunctions.Get_y_by_row(this.row);
        this.node.position = v3(x, y, 0);
    }
    Destroy() {
        let index = GameData.arrStopBlock.indexOf(this);
        if (index > -1) {
            GameData.arrStopBlock.splice(index, 1);
        }

        this.node.destroy();
    }
}